<template>
	<view class="outBox">
		<u-navbar leftText="我的预约" leftIconColor="#fff" :autoBack="true" bgColor="rgba(0, 0, 0, 0.6)">
			<view class="left-slot" slot="left">
				<u-icon name="arrow-left" color="#fff"></u-icon>
				<text>{{ '我的预约' }}</text>
			</view>
		</u-navbar>
		 <video :src="videoUrl + '/mp4/1.mp4'" autoplay :controls="false" loop object-fit="cover"></video>
		<view class="content" :style="{
			paddingTop:menuHeight + 'px',
		}">
			<view class="tabs">
				<view class="tab" :class="curType == 1 ? 'active' : ''" @click="changeTab(1)">
					<text>秒杀价</text>
				</view>
				<view class="tab" :class="curType == 2 ? 'active' : ''" @click="changeTab(2)">
					<text>竞价</text>
				</view>
			</view>
      <view class="items" v-for="item in dataList">
        <view class="item" :style="{
					backgroundImage:`url(${bg})`,
				}">
          <view class="left">
            <view class="top">
              <view class="tag">
                <text>桌号</text>
              </view>
              <view class="value">
                <text>{{item.counterNo}}</text>
              </view>
            </view>
            <view class="bottom">
              <text>预约时间：{{item.createTime}}</text>
            </view>
          </view>
          <view class="right">
            <view class="price">
              <text v-if="curType == 1"  style="font-size: 32rpx">低消：</text>
              <text v-if="curType == 1">{{item.biddingPrice || item.minPrice}}</text>
              <text v-if="curType == 2" style="font-size: 32rpx">报价：</text>
              <text v-if="curType == 2">{{item.biddingPrice || item.minPrice}}</text>
            </view>
            <view class="status" :class="[getStatusColor(item.bookingStatus || item.biddingStatus)]">
              <text>{{item.bookingStatus || item.biddingStatus}}</text>
            </view>
          </view>
        </view>
      </view>
		</view>
	</view>
</template>

<script>
	import {
		getWXStatusHeight
	} from '@/utils/index.js'

  import bg from "@/static/mine/bg2.png"

	import {
		findMyBookingListApi,
		findMyBiddingListApi
	} from '../../api/api'
	export default {
		data() {
			return {
				// 胶囊的宽度
				barWidth: 0,
				menuHeight: 0,
				dataList: [],
				baseImgUrl: this.$baseImgUrl,
				videoUrl: this.$videoUrl,
				curType: 1,
        bg: bg,
			}
		},
		onLoad() {
			let obj = getWXStatusHeight()
			this.barWidth = obj.barWidth + 3
			this.menuHeight = obj.menuHeight
			this.changeTab(1)
		},
		methods: {
      getStatusColor(name){
        if(name == '竞价成功' || name == '已到店'){
          return ''
        }else if(name == '预约成功'){
          return 'status2'
        }else if(name == '竞价失败'){
          return 'status3'
        }
      },
			changeTab(type) {
				this.curType = type
				if (type == 1) {
					this.findMyBookingList()
				} else {
					this.findMyBiddingList()
				}
			},
			// 获取竞价列表
			async findMyBiddingList() {
				const res = await findMyBiddingListApi()
				if (res.code == 200) {
					this.dataList = res.data
				}
			},
			// 获取一口价列表
			async findMyBookingList() {
				const res = await findMyBookingListApi()
				if (res.code == 200) {
					this.dataList = res.data
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.items {
  margin-top: 30rpx;
  .item{
    width: 686rpx;
    height: 176rpx;
    background-size: 100% 100%;
    display: flex;
    justify-content: space-between;
    padding: 42rpx 50rpx;
    box-sizing: border-box;
    margin-bottom: 18rpx;
    .right{
      display: flex;
      flex-direction: column;
      align-items: center;
      .price{
        font-weight: 500;
        font-size: 36rpx;
        color: #FFFFFF;
        line-height: 36rpx;
        text-align: right;
        font-style: normal;
        margin-bottom: 18rpx;
        display: flex;
        align-items: center;
      }
      .status{
        width: 124rpx;
        height: 40rpx;
        background: rgba(52,145,250,0.16);
        border-radius: 14rpx;
        border: 2rpx solid #3491FA;
        display: flex;
        align-items: center;
        justify-content: center;
        text{
          font-weight: 500;
          font-size: 24rpx;
          color: #3491FA;
          line-height: 24rpx;
          text-align: right;
          font-style: normal;
        }
      }
      .status1{
        background: rgba(255,154,46,0.16);
        border: 2rpx solid #FF9A2E;
        text{
          color: #FF9A2E;
        }
      }
      .status2{
        background: rgba(15,198,194,0.16);
        border: 2rpx solid #0FC6C2;
        text{
          color: #0FC6C2;
        }
      }
      .status3{
        background: rgba(255,96,72,0.16);
        border: 2rpx solid #FF6048;
        text{
          color: #FF6048;
        }
      }
    }
    .left{
      .top{
        display: flex;
        margin-bottom: 26rpx;
      }
      .bottom{
        font-weight: 400;
        font-size: 24rpx;
        color: #86909C;
        line-height: 24rpx;
        text-align: left;
        font-style: normal;
      }
    }
    .tag{
      width: 76rpx;
      height: 40rpx;
      background: #FF9A2E;
      border-radius: 14rpx;
      margin-right: 16rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      text{
        font-weight: 500;
        font-size: 24rpx;
        color: #FFFFFF;
        line-height: 24rpx;
        text-align: right;
        font-style: normal;
      }
    }
    .value{
      text{
        font-weight: 500;
        font-size: 36rpx;
        color: #FFFFFF;
        line-height: 36rpx;
        text-align: right;
        font-style: normal;
      }
    }
  }
}

	.tabs {
		display: flex;
		margin-bottom: 28rpx;
		margin-top: 40rpx;

		.tab {
			display: flex;
			justify-content: center;
			align-items: center;
			margin-right: 48rpx;

			text {
				color: #86909C;
			}
		}

		.active {
			position: relative;

			&::after {
				content: "";
				display: inline-block;
				position: absolute;
				bottom: -20rpx;
				width: 56rpx;
				height: 6rpx;
				background: #0FC6C2;
				border-radius: 4rpx;
			}

			text {
				color: #fff;
			}
		}
	}

	.content {
		position: relative;
		box-sizing: border-box;
		min-height: 100vh;
		padding: 0 32rpx;
		background: rgba(0, 0, 0, 0.6);
	}

	.left-slot {
		color: #fff;
		display: flex;
		align-items: center;

		image {
			width: 40rpx;
			margin-right: 30rpx;
		}
	}

	video {
		width: 100%;
		height: 100%;
		object-fit: cover;
		/* 确保视频填充整个容器，可能会裁剪视频 */
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 0;
	}

	.outBox {}
</style>
